<template>
  <div class="map-contant">
    <slot></slot>
  </div>
</template>
<script>
// -------------- 初始化 -------------------
import InitMapMixin from "../mixins/initmap"
// -------------- 图层 ----------------
// -------------- 其他功能 -------------
// import {addDEForHeat} from "../DistricExplorer/heatMap";
import {addHeatMap, setHeatData} from "../heatMap/initHeatMap"
import deMixin from "../DistricExplorer/mixin/deMixin";
// ------------- axios --------------------
import {getHeatMapData, selectHeatMapData} from "../../../api/bigData";

export default {
  mixins: [InitMapMixin,deMixin],
  name:"heatmap",
  mounted() {
    // addDEForHeat(this.mapInfo.adcode, this.map, this);
    addHeatMap(this.map);
    this.getHeatMapData();
    this.map.setRotation(65)
  },
  data() {
    return {}
  },
  methods: {
    // ------------------ 检索热力图 ----------------
    /**
     * 获取热力图数据
     */
    getHeatMapData: function () {
      const pd = {}
      getHeatMapData(pd)
          .then(res => {
            let dataContent = res.data.data;
            setHeatData(dataContent);
          })
          .catch(err => {
            console.error(err)
          })
    },
    /**
     * 检索热力图数据
     * @param pd
     */
    selectHeatMapData: function (pd) {
      selectHeatMapData(pd)
          .then(res => {
            let heatData = res.data.data;
            if (heatData.length === 0) {
              this.$message.info("无数据")
            } else {
              this.$message.success("获取成功")
            }
            setHeatData(heatData);
          })
          .catch(err => {
            console.error(err)
          })
    }
  },
  props: {
    selectFrom: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  watch: {
    selectFrom: function (val) {
      this.selectHeatMapData(val);
    }
  }
};
</script>
<style scoped>
.map-contant {
  height: 100%;
  width: 100%;
}
</style>
